/*
 * @Author: szx
 * @Date: 2021-12-02 16:24:08
 * @LastEditTime: 2021-12-02 16:33:26
 * @Description:
 * @FilePath: \leetcode\100-199\119\119.js
 */
// var getRow = function (rowIndex) {
//     let res = [];
//     for (let i = 0; i < rowIndex + 1; i++) {
//         let temp = new Array(i + 1).fill(1);
//         for (let j = 1; j < i; j++) {
//             temp[j] = res[j - 1] + res[j];
//         }
//         res = temp;
//     }
//     return res;
// };

var getRow = function (rowIndex) {
    const row = new Array(rowIndex + 1).fill(0);
    row[0] = 1;
    for (let i = 1; i <= rowIndex; ++i) {
        for (let j = i; j > 0; --j) {
            row[j] += row[j - 1];
        }
    }
    return row;
};
console.log(getRow(3));
